<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>录用结果</title>
    <!-- 引入element-ui样式 -->
    <link rel="stylesheet" href="../../../plugins/element-ui/index.css">

    <style>
        *{
            margin: 0;
            padding: 0;
        }
    </style>
    <!--    上传图片样式-->
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }
    </style>

</head>
<body>
<div id="app">


    <!--1.导航栏-->
    <div style="z-index: 999;position:fixed;width: 100%">
        <el-menu
                class="el-menu-demo"
                mode="horizontal"
                background-color="#545c64"
                text-color="#fff"
                active-text-color="#ffd04b">
            <el-menu-item index="1" @click="url(1)" style="margin-left: 200px">首页</el-menu-item>
            <el-menu-item index="3" @click="url(3)">录用结果</el-menu-item>
            <el-menu-item index="4" @click="url(4)">工资详情|反馈信息</el-menu-item>
            <el-menu-item index="5" @click="url(5)">修改个人信息</el-menu-item>

            <el-submenu index="6"  style="margin-left: 400px">
                <template slot="title"><i class="el-icon-user"></i></template>
                <el-menu-item index="6-1" @click="url(6)">退出登录</el-menu-item>
            </el-submenu>


        </el-menu>
    </div>

    <!--   注： 这个盒子的作用是把轮播图给顶到下面去，避免导航栏position的fixed属性将轮播图给覆盖-->
    <div style="width: 100%;height:58px "></div>

    <!--    标题div-->
    <div style="position:absolute;margin:50px 0 0 70px;  width: 90%;height: 300px;background-color: #f2e2d0">
        <div style="margin:50px 0 0 575px;background-color: black;color:white;width: 200px;height: 45px"><p style="line-height:45px;text-align: center">Welcome</p></div>
        <div style="margin: 0 0 0 350px;"><h1>This is your personal employment result</h1></div>
        <div @click="toType" style="cursor:pointer;margin:0 0 0 600px;background-color: #24b5e1;color:white;width: 150px;height: 60px"><h2 style="line-height:60px;text-align: center"> TO HOME</h2></div>
    </div>

    <div style="margin:400px 0 100px 700px;">
        <h1>录用表格</h1>
    </div>

    <!--录用结果-->
    <div style="margin:0px 0 200px 70px;width: 1320px">
        <template>
            <el-table :data="dataList" border style="width: 100%">
                <el-table-column  fixed prop="jobName" label="岗位名称"   align="center"></el-table-column>

                <el-table-column prop="jobTime" label="工作时段"   align="center"></el-table-column>

                <el-table-column prop="workTime" label="工时"   align="center"></el-table-column>


                <el-table-column prop="salary" label="时薪"   align="center"></el-table-column>

                <el-table-column prop="resume" label="个人简历"   align="center"></el-table-column>

                <el-table-column prop="statusApplication" label="录用状态"   align="center">
                    <div slot-scope="{ row }">
                        <h2 v-if="row.statusApplication=='true'"  style="color: green">已通过</h2>
                        <h2 v-else-if="row.statusApplication=='false'" style="color: red">未通过</h2>
                    </div>
                </el-table-column>


                <el-table-column  fixed="right" label="操作1"  align="center">
                    <template slot-scope="scope">
                        <el-button  @click="down(scope.row)" type="text" size="small">查看个人简历</el-button>
                        <el-button @click="Up_dialogShow(scope.row)" type="text" size="small">修改个人简历</el-button>
                    </template>
                </el-table-column>
                <el-table-column  fixed="right" label="操作2"  align="center">
                    <template slot-scope="scope">
                        <el-button @click="DeletePostApplication(scope.row)" type="text" size="small">删除</el-button>
                    </template>
                </el-table-column>

            </el-table>

            <!--分页组件-->
            <el-pagination
                    class="pagination"
                    @current-change="handleCurrentChange"
                    :current-page="pagination.currentPage"
                    :page-size="pagination.pageSize"
                    layout="total, prev, pager, next, jumper"
                    :total="pagination.total">
            </el-pagination>
        </template>

        <!--2.修改简历弹框-->
        <el-dialog :title="工时录入" style="height: 650px"  :visible.sync="dialog_update">
            <el-form :model="formData_update" :rules="rules" ref="formData_update" label-width="100px" class="demo-formData_update">

<!--                <el-form-item  label="工时时长：" prop="workTime">-->
                <el-form-item  label="修改简历：">
                    <el-upload
                            class="upload-demo"
                            drag
                            action="http://localhost:8080/files/uploadFile2"
                            :on-success="handleAvatarSuccess2"
                            :on-remove="handleRemove"
                            :file-list="fileList"
                            multiple>
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
                        <div class="el-upload__tip" slot="tip">只能上传jpg/png文件，且不超过500kb</div>
                    </el-upload>
                </el-form-item>


                <el-form-item>
                    <el-button type="primary" @click="UpdatePostApplication">确定修改</el-button>
                    <el-button @click="center">取消</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>

    </div>

</div>




<script src="../../../plugins/vue/vue.js"></script>

<!-- 引入element-ui组件库 -->
<script src="../../../plugins/element-ui/index.js"></script>

<!-- 引入axios -->
<script src="../../../plugins/axios/axios.min.js"></script>

<script>
    new Vue({
        el:'#app',    //element
        data:{

            studentInfo:{}, //当前用户信息

            //显示的数据
            dataList:[],

            //element-ui分页插件
            pagination: {//分页相关模型数据 1
                currentPage: 1,//当前页码1
                pageSize:5,//每页显示的记录数1
                total:0,//总记录数1
            },

            //修改弹框内容
            formData_update:{},
            dialog_update:false,


            //文件上传
            fileList: [
                {name: '', url: ''}
            ],

        },
        created() {
            const studentInfo = window.localStorage.getItem('student')
            console.log("studentInfo1:::"+studentInfo)
            if (studentInfo) {
                this.studentInfo = JSON.parse(studentInfo)
            }
            console.log("studentInfo2:::"+studentInfo)
            if (this.studentInfo==null){
                this.$message.error("您还没登录账号!")
            }

            this.getAll()
        },
        methods:{
            url(code){
                if (code==1){
                    window.location.href='../index.html';
                }else  if (code==2){
                    window.location.href='teleplay.html';
                }else  if (code==3){
                    window.location.href='applicationResult.html';
                }else  if (code==4){
                    window.location.href='salaryDetails.html';
                }else  if (code==5){
                    window.location.href='updateMyself.html';
                }else  if (code==6){
                    localStorage.setItem('student',null)
                    window.location.href='../../Login/StudentLogin.html';
                }
            },

            getAll() {
                parent = "?stuNumber="+this.studentInfo.data.stuNumber;
                axios.get("/postApplications/getPagePostApplication/" + this.pagination.currentPage + "/" + this.pagination.pageSize +"/2"+ parent).then((res) => {
                    console.log(res)
                    this.dataList = res.data.data.records
                    this.pagination.total = res.data.data.total
                })
            },
            //切换页码
            handleCurrentChange(currentPage) {
                console.log("切换页码:")
                this.pagination.currentPage = currentPage;
                console.log(currentPage)
                this.getAll();
            },

            //修改弹框的显示和隐藏
            Up_dialogShow(row){

                //数据回显
                this.formData_update = row

                this.fileList=[{name:"",url:""}]   //bug：因为点击添加时候已经将fileList制空，里面的‘name’，‘url’已经不存在，所以得重新初始化一下
                this.fileList[0].name=row.resume
                this.fileList[0].url=`/files/downloadFile?name=${row.resume}`

                //弹框显示
                this.dialog_update=true
            },

            //确定修改
            UpdatePostApplication(){

                console.log("this.formData_update1::")
                console.log(this.formData_update)

                axios.put("/postApplications/updatePostApplication",this.formData_update).then((res)=>{     //修改数据回显
                    if (res.data.code){
                        this.$message.success(res.data.msg)
                    }else{
                        this.$message.error(res.data.msg)
                    }
                }).finally(()=>{
                    this.getAll();
                    this.dialog_update=false;
                })
            },

            center() {
                this.dialog_update=false
                this.dialog_add=false
                this.$message.info("取消操作")
                this.getAll()
            },


            toType(){
                window.location.href='../index.html';
            },


            /**
             * 简历文件上传
             *
             */
            handleRemove(file, fileList) {
                console.log("file, fileList2::")
                console.log(file, fileList)
                this.formData_update.resume=''
            },
            handlePreview(file) {
                console.log(file);
            },
            handleAvatarSuccess2(res,file) {

                console.log("res,file")
                console.log(res)
                console.log(file)
                this.formData_update.resume=res.data
            },


            //简历文件下载
            down(row){
                // alert("qwe")
                if (this.studentInfo.data.resume!=null){
                    window.location.href="http://localhost:8080/files/downloadFile2?name="+row.resume
                }else {
                    this.$message.error("没有附件下载")
                }
            },


        }

    })
</script>

</body>
</html>